/**
 * Author: runlin.tang
 * Creation Time: 2016-08-31.
 * Description:.网络连接功能，你要先get 一个接口：get_wan_type
 这个接口我会返回给你相应的值，如果是ＰＰＰＯＥ的，就返回pppoe 的相关值，如果是中继就给你返回SSID与password,如果是DHCP,就给你返回DHCP的三个参数

 */
define(['jquery','../../common/ajax/ajax','../v/linknetV'],
    function($,ajax,linknetV) {
        function example(postdata){
            ajax({
                url:interfaces.page_wan_settings.url,
                dataType:interfaces.page_wan_settings.dataType,
                type:interfaces.page_wan_settings.type,
                data:postdata,
                contentType: 'application/json',
                cache:{
                    use:false,
                    name:'',
                    time:10
                },
                isOk:function(data){
                    var datas = '';
                    if(useNetData){
                        datas = data;
                    }else{
                        datas = data.page_wan_settings;
                    }
                    if(datas.data.wan_set_status == -1){
                        $(".contect-state span").addClass('warning');
                        $(".contect-state span").text('未连接');
                    }else{
                        $(".contect-state span").removeClass('warning');
                        $(".contect-state span").text('已连接');
                        $(".ly-tip").remove();
                        if(datas.data.wan_type == 0){
                            $(".wan_ip").html(datas.data.wan_dhcpip);
                            $(".wan_mask").html(datas.data.wan_dhcpnetmask);
                            $(".wan_dns").html(datas.data.wan_dhcpdns);
                        }
                        if(datas.data.wan_type == 1){
                            if(datas.data.wan_pppoe_errormsg == 0){
                                var html = '<div class="ly-tip"><i></i><span>PPPOE服务器没有响应！</span></div>';
                            }else if(datas.data.wan_pppoe_errormsg == 1){
                                var html = '<div class="ly-tip"><i></i><span>PPPOE服务器连接超时！</span></div>';
                            }else if(datas.data.wan_pppoe_errormsg == 2){
                                var html = '<div class="ly-tip"><i></i><span>用户名或密码错误！</span></div>';
                            }else if(datas.data.wan_pppoe_errormsg == 3){
                                var html = '<div class="ly-tip"><i></i><span>没有发现PPPOE服务器！</span></div>';
                            }else if(datas.data.wan_pppoe_errormsg == 4){
                                var html = '<div class="ly-tip"><i></i><span>PPPOE无法连接外网！</span></div>';
                            }
                            $(".content").append(html);
                        }
                    }
                }
            });
        }
        return example;
    });